package com.hkts.naturalgasauthentication.base.controller;


import com.hkts.management.common.utils.Result;
import com.hkts.management.common.utils.ResultUtil;
import com.hkts.naturalgasauthentication.base.entity.Company;
import com.hkts.naturalgasauthentication.base.service.CompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/authentication/company")
@Api(tags = "公司管理接口")
public class CompanyController {
    @Autowired
    private CompanyService companyService;

    @PostMapping("/saveCompany")
    @ApiOperation("新增公司")
    public Result<Object> saveCompany(Company company){
        return ResultUtil.data(companyService.save(company));
    }

    @GetMapping("/findAll")
    @ApiOperation("公司列表")
    public Result< List<Company>> findAll(){
        List<Company> all = companyService.findAll(Specification.where(null));
        return ResultUtil.data( all);
    }



}
